package com.edu.koudingmusic;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

import com.edu.koudingmusic.tools.Constant;
import com.lidroid.xutils.DbUtils;

/**
 * Created by Ming on 2016/2/24.
 * email 1715944993@qq.com
 */
public class BaseApplication extends Application {

    public static SharedPreferences mSharedPreferences;

  /*  public static DbManager.DaoConfig daoConfig;

    public DbManager.DaoConfig getDaoConfig() {
        File file = new File(Environment.getExternalStorageDirectory().getPath());
        daoConfig = new DbManager.DaoConfig()
                .setDbName(Constant.DB_NAME)
                .setDbDir(file)
                .setDbVersion(1)
                .setAllowTransaction(true)
                .setDbUpgradeListener(new DbManager.DbUpgradeListener() {
                    @Override
                    public void onUpgrade(DbManager db, int oldVersion, int newVersion) {
                        // 开启WAL, 对写入加速提升巨大
                        db.getDatabase().enableWriteAheadLogging();
                    }
                }).setDbUpgradeListener(new DbManager.DbUpgradeListener() {
                    @Override
                    public void onUpgrade(DbManager db, int oldVersion, int newVersion) {
                        // TODO: ...
                        // db.addColumn(...);
                        // db.dropTable(...);
                        // ...
                        // or
                        // db.dropDb();
                    }
                });
        return daoConfig;
    }
*/
    // 低版本的 xUtils
    public static DbUtils sDbUtils;

    public static Context sContext;
    @Override
    public void onCreate() {
        super.onCreate();
        mSharedPreferences = getSharedPreferences(Constant.SP_NAME, Context.MODE_PRIVATE);
        //x.Ext.init(this);
        sDbUtils = DbUtils.create(getApplicationContext(), Constant.DB_NAME);
        sContext  =getApplicationContext();
    }
}
